# -*- coding: utf-8 -*-
"""
Created on Wed Nov 14 20:48:47 2018

@author: 陈忠涛
"""

import pandas as pd
from sqlalchemy import create_engine

db = create_engine('mysql+pymysql://root:chenzt@localhost:3306/czt_blog') # 使用create_engine连接数据库
posts_query = 'select * from comments'  # sql语句：查询
posts_data = pd.read_sql_query(posts_query, db)  # 执行查询语句

posts_data.to_excel('blog_data.xlsx', index = False)
print(type(posts_data))
